package com.lcsw.background.controller;

import com.alibaba.fastjson.JSONObject;
import com.lcsw.background.service.QueryResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 查询支付
 */
@RestController
public class QueryResultController {
    @Autowired
    QueryResultService queryResultService;

    @Autowired
    HttpServletRequest request;

    @RequestMapping("/queryResult")
    public JSONObject queryResult(@RequestBody(required = false) String json1) {
        String terminal_trace = "";
        if (json1 != null) {
            JSONObject json = (JSONObject) JSONObject.parse(json1);
            terminal_trace = json.getString("terminal_trace");
        }
        JSONObject json = (JSONObject) JSONObject.parse(json1);
        JSONObject object = new JSONObject();
        if (StringUtils.isEmpty(json.getString("terminal_trace"))) {
            object.put("msg", "请先登录!");
            return object;
        } else {
            String result = queryResultService.QueryResult(terminal_trace);
            object.put("result", result);
        }
        return object;
    }
}
